import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';
import axios from "axios";
import {Tool} from '@/utils/tool.ts'

axios.interceptors.request.use(function (config) {
    console.log('请求参数：', config);
    // @ts-ignore
    console.log('token : ' + store.state.token);
    // @ts-ignore
    const token = store.state.token;
    if (Tool.isNotEmpty(token)) {
        // @ts-ignore
        config.headers.authorization = token;
        console.log("请求headers增加token:", token);
    }
    return config;
}, error => {
    return Promise.reject(error);
});

axios.interceptors.response.use(function (response) {
    console.log('返回结果：', response);
    return response;
}, error => {
    return Promise.reject(error);
});

createApp(App).use(store).use(router).use(Antd).mount('#app')
